package com.ruoyi.project.system.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.project.system.domain.SmIncome;
import com.ruoyi.project.system.domain.vo.CashOut;
import com.ruoyi.project.system.domain.vo.Ranking;
import com.ruoyi.project.system.domain.vo.TeamSmIncome;
import com.ruoyi.project.system.domain.vo.UserRecentlyIncome;
import org.apache.ibatis.annotations.Select;

/**
 * 收入Mapper接口
 */
public interface SmIncomeMapper {

    List<UserRecentlyIncome> userRecentlyIncome(Long userId, Integer pageNum);

    List<Ranking> ranking();

    @Select("select IFNULL(sum(amount),0) from sm_income where userId = #{userId} and status in ('2','4');")
    Float totalIncome(Long userId);

    @Select("select IFNULL(sum(amount),0) from sm_income where userId = #{userId} and status = '4';")
    Float cashOut(Long userId);

    @Select("select IFNULL(sum(amount),0) from sm_income where userId = #{userId} and status in ('3','5','6');")
    Float totalRefund(Long userId);

    List<CashOut> cashOutList(Long userId);

    List<SmIncome> untreatedRefundList(Long userId);

    List<TeamSmIncome> teamSmIncomeList(Long userId);

    void paySuccessSetIncome(String payOrderNo);

    void cashOutSetIncome(List<Integer> ids, String oldStatus, String newStatus, String extractId);

    void refundSetIncome(Integer id, String oldStatus, String newStatus);

    SmIncome selectSmIncomeById(Integer id);

    List<SmIncome> selectSmIncomeListByUserId(Long userId);

    /**
     * 查询收入列表
     *
     * @param smIncome 收入
     * @return 收入集合
     */
    List<SmIncome> selectSmIncomeList(SmIncome smIncome);

    /**
     * 新增收入
     *
     * @param smIncome 收入
     * @return 结果
     */
    public int insertSmIncome(SmIncome smIncome);

    /**
     * 修改收入
     *
     * @param smIncome 收入
     * @return 结果
     */
    public int updateSmIncome(SmIncome smIncome);

}
